/**
 * Created by Administrator on 2015/6/5.
 */
var fs=require('fs');
var util=require('util');
var stream=require('stream');

/*让自定义的writeStream继承Writable方法*/
function ZfWriteStream(){
    stream.Writable.call(this);
}
//继承,让ZfWriteStream继承stream.writable
util.inherits(ZfWriteStream,stream.Writable);
/*扩展write方法*/
ZfWriteStream.prototype._write=function(chunk,encoding,cb){
    //chunk是数据,在write中需要自己去消费数据，而chunk相当于push进来的数据
    //将chunk进来的数据进行输出
    console.log(chunk.toString());
    cb();
};

var zfWriteStream=new ZfWriteStream();
//zfWriteStream如何往流中写数据
zfWriteStream.write('火龙果','utf8',function(){
    console.log('营养美味！');
});






















































































